---
title: Best Practices
description: Tips and examples for writing effective prompts in Latitude.
---

Writing effective prompts is key to getting the best results from AI models. Here are some best practices and examples specific to working within the Latitude platform.

## General Best Practices

1.  **Be Specific and Clear**: Avoid ambiguity. Clearly state the task, desired format, context, and constraints.

    - **Bad**: "Write about Latitude."
    - **Good**: "Write a 3-paragraph introduction to Latitude for a non-technical audience, highlighting its key benefits for prompt management and evaluation."

2.  **Provide Context**: Give the model relevant background information it might need.

    - **Example**: If asking for a summary of a meeting, provide the meeting transcript or key discussion points.

3.  **Define the Persona/Role**: Tell the model _who_ it should be.

    - **Example**: `<system>You are a helpful and friendly customer support agent for a SaaS company.</system>`
    - **Note**: It can be helpful to use made up tags to organize information for the model.
      -  **Example:**  `<rules> You must never produce more than 5 lines. </rules>`

4.  **Specify the Output Format**: Use instructions or [JSON Schema](/guides/prompt-manager/json-output) to guide the format.

    - **Example**: "Provide the answer as a JSON object with keys 'pros' and 'cons', each containing a list of strings."
    - **Example**: Use the `schema` configuration for reliable JSON.

5.  **Use Examples (Few-Shot Prompting)**: Provide examples of desired input/output pairs within the prompt.

    ```markdown
    <user>
    Text: "This is great!" 
    Sentiment: Positive
    </user>
    <assistant>Okay.</assistant>
    <user>
    Text: "I am not happy." 
    Sentiment: Negative
    </user>
    <assistant>Okay.</assistant>
    <user>
    Text: "{{ user_input }}" 
    Sentiment:
    </user>
    ```

6.  **Iterate and Test**: Use the [Playground](/guides/prompt-manager/playground) extensively. Start simple and gradually add complexity. Test with various inputs.

7.  **Break Down Complex Tasks**: Use [Chains](/promptl/advanced/chains) or [Agents](/guides/prompt-manager/agents) for multi-step processes rather than trying to do everything in one giant prompt.

## Latitude-Specific Tips

- **Leverage PromptL**: Use variables (`{{ }}`), conditionals (`{{ if … }}`), loops (`{{ for … }}`), and snippets (`<prompt path="...">`) for dynamic and reusable prompts. See the [PromptL documentation](/promptl/getting-started/introduction).
- **Use Configuration Wisely**: Tune `temperature`, `maxTokens`, etc., in the [configuration block](/guides/prompt-manager/configuration) for desired output style and length.
- **Utilize Tools**: Don't make the model guess information it can look up. Provide [Tools](/guides/prompt-manager/tools) for accessing external data or functions (e.g., `latitude/search` for web searches).
- **Employ Agents for Autonomy**: For tasks requiring planning and dynamic tool use, define your prompt as an [Agent](/guides/prompt-manager/agents).
- **Manage Versions**: Use [Version Control](/guides/prompt-manager/version-control) to track changes and collaborate safely.
- **Evaluate Systematically**: Use [Evaluations](/guides/evaluations/overview) to measure prompt quality and identify areas for improvement.

## Example: Customer Support Email Generator

```markdown
---
provider: anthropic
model: claude-3-haiku-20240307
temperature: 0.5
schema:
  type: object
  properties:
    subject:
      type: string
      description: A concise and relevant email subject line.
    body:
      type: string
      description: The full email body, formatted professionally.
  required: [subject, body]
tools:
  - get_customer_details:
      description: Retrieves customer details based on email address.
      parameters:
        type: object
        properties:
          email:
            type: string
            description: The customer's email address.
        required: [email]
---

<system>
You are a helpful customer support agent. Your task is to draft a polite and helpful email response to a customer query.

Use the provided tools if you need more customer information. Address the customer by name if available.

Keep the tone professional and empathetic.
Structure the response clearly.
Ensure the final output matches the required JSON schema.
</system>

<user>
Customer Email: {{ customer_email }}
Query: {{ customer_query }}
</user>

{# Agent might call get_customer_details here if name isn't obvious #}
{# Then it will generate the JSON output for subject and body #}
```

This example demonstrates:

- Role setting (`<system>`).
- Using variables (`{{ customer_email }}`, `{{ customer_query }}`).
- Defining and enabling a custom tool (`get_customer_details`).
- Enforcing structured output (`schema`).
- Clear instructions within the system message.
